Fix problem where computation was depending on widget->allocation instead
authorOwen Taylor <otaylor@redhat.com>
Mon, 31 Jul 2000 22:59:29 +0000 (22:59 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Mon, 31 Jul 2000 22:59:29 +0000 (22:59 +0000)
Mon Jul 31 18:37:36 2000  Owen Taylor  <otaylor@redhat.com>

* gtk/gtkentry.c (entry_adjust_scroll): Fix problem where computation
was depending on widget->allocation instead of the width of text_area,
which was incorrect for subclasses like GtkSpinButton.

* gdk/gdkpango.c (gdk_draw_layout): Fix a couple of typos
with width == 1 tests that should be width == -1.

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gdk/gdkpango.c
gtk/gtkentry.c

index e58e000f0ae994cb0085f621f5e872b2ecf8ac09..c4d03bb230a5234abc6829c42aa5efcce57bbde6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Mon Jul 31 18:37:36 2000  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkentry.c (entry_adjust_scroll): Fix problem where computation
+       was depending on widget->allocation instead of the width of text_area,
+       which was incorrect for subclasses like GtkSpinButton.
+
+       * gdk/gdkpango.c (gdk_draw_layout): Fix a couple of typos
+       with width == 1 tests that should be width == -1.
+
 Mon Jul 31 16:45:48 2000  Owen Taylor  <otaylor@redhat.com>
 
        * gdk/gdkwindow.c (gdk_window_process_updates_internal): Replace broken, 
index e58e000f0ae994cb0085f621f5e872b2ecf8ac09..c4d03bb230a5234abc6829c42aa5efcce57bbde6 100644 (file)
@@ -1,3 +1,12 @@
+Mon Jul 31 18:37:36 2000  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkentry.c (entry_adjust_scroll): Fix problem where computation
+       was depending on widget->allocation instead of the width of text_area,
+       which was incorrect for subclasses like GtkSpinButton.
+
+       * gdk/gdkpango.c (gdk_draw_layout): Fix a couple of typos
+       with width == 1 tests that should be width == -1.
+
 Mon Jul 31 16:45:48 2000  Owen Taylor  <otaylor@redhat.com>
 
        * gdk/gdkwindow.c (gdk_window_process_updates_internal): Replace broken, 
index e58e000f0ae994cb0085f621f5e872b2ecf8ac09..c4d03bb230a5234abc6829c42aa5efcce57bbde6 100644 (file)
@@ -1,3 +1,12 @@
+Mon Jul 31 18:37:36 2000  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkentry.c (entry_adjust_scroll): Fix problem where computation
+       was depending on widget->allocation instead of the width of text_area,
+       which was incorrect for subclasses like GtkSpinButton.
+
+       * gdk/gdkpango.c (gdk_draw_layout): Fix a couple of typos
+       with width == 1 tests that should be width == -1.
+
 Mon Jul 31 16:45:48 2000  Owen Taylor  <otaylor@redhat.com>
 
        * gdk/gdkwindow.c (gdk_window_process_updates_internal): Replace broken, 
index e58e000f0ae994cb0085f621f5e872b2ecf8ac09..c4d03bb230a5234abc6829c42aa5efcce57bbde6 100644 (file)
@@ -1,3 +1,12 @@
+Mon Jul 31 18:37:36 2000  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkentry.c (entry_adjust_scroll): Fix problem where computation
+       was depending on widget->allocation instead of the width of text_area,
+       which was incorrect for subclasses like GtkSpinButton.
+
+       * gdk/gdkpango.c (gdk_draw_layout): Fix a couple of typos
+       with width == 1 tests that should be width == -1.
+
 Mon Jul 31 16:45:48 2000  Owen Taylor  <otaylor@redhat.com>
 
        * gdk/gdkwindow.c (gdk_window_process_updates_internal): Replace broken, 
index e58e000f0ae994cb0085f621f5e872b2ecf8ac09..c4d03bb230a5234abc6829c42aa5efcce57bbde6 100644 (file)
@@ -1,3 +1,12 @@
+Mon Jul 31 18:37:36 2000  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkentry.c (entry_adjust_scroll): Fix problem where computation
+       was depending on widget->allocation instead of the width of text_area,
+       which was incorrect for subclasses like GtkSpinButton.
+
+       * gdk/gdkpango.c (gdk_draw_layout): Fix a couple of typos
+       with width == 1 tests that should be width == -1.
+
 Mon Jul 31 16:45:48 2000  Owen Taylor  <otaylor@redhat.com>
 
        * gdk/gdkwindow.c (gdk_window_process_updates_internal): Replace broken, 
index e58e000f0ae994cb0085f621f5e872b2ecf8ac09..c4d03bb230a5234abc6829c42aa5efcce57bbde6 100644 (file)
@@ -1,3 +1,12 @@
+Mon Jul 31 18:37:36 2000  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkentry.c (entry_adjust_scroll): Fix problem where computation
+       was depending on widget->allocation instead of the width of text_area,
+       which was incorrect for subclasses like GtkSpinButton.
+
+       * gdk/gdkpango.c (gdk_draw_layout): Fix a couple of typos
+       with width == 1 tests that should be width == -1.
+
 Mon Jul 31 16:45:48 2000  Owen Taylor  <otaylor@redhat.com>
 
        * gdk/gdkwindow.c (gdk_window_process_updates_internal): Replace broken, 
index e58e000f0ae994cb0085f621f5e872b2ecf8ac09..c4d03bb230a5234abc6829c42aa5efcce57bbde6 100644 (file)
@@ -1,3 +1,12 @@
+Mon Jul 31 18:37:36 2000  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkentry.c (entry_adjust_scroll): Fix problem where computation
+       was depending on widget->allocation instead of the width of text_area,
+       which was incorrect for subclasses like GtkSpinButton.
+
+       * gdk/gdkpango.c (gdk_draw_layout): Fix a couple of typos
+       with width == 1 tests that should be width == -1.
+
 Mon Jul 31 16:45:48 2000  Owen Taylor  <otaylor@redhat.com>
 
        * gdk/gdkwindow.c (gdk_window_process_updates_internal): Replace broken, 
index 561a1cce6e254836a84aa6ed7bffe32288f572e2..85655e302df79bea4266cae4b8b3b609ff80365f 100644 (file)
@@ -278,9 +278,9 @@ gdk_draw_layout (GdkDrawable     *drawable,
       
       pango_layout_line_get_extents (line, NULL, &logical_rect);
 
-      if (width != 1 && align == PANGO_ALIGN_RIGHT)
+      if (width != -1 && align == PANGO_ALIGN_RIGHT)
        x_offset = width - logical_rect.width;
-      else if (width != 1 && align == PANGO_ALIGN_CENTER)
+      else if (width != -1 && align == PANGO_ALIGN_CENTER)
        x_offset = (width - logical_rect.width) / 2;
       else
        x_offset = 0;
index b4e424f91ad351eff9293d389d1fd30ebbad8b25..050709181a3e05756cb53a18dadf30fe62b426fb 100644 (file)
@@ -589,6 +589,8 @@ gtk_entry_realize (GtkWidget *widget)
     gtk_editable_claim_selection (editable, TRUE, GDK_CURRENT_TIME);
 
   gtk_im_context_set_client_window (entry->im_context, entry->text_area);
+
+  entry_adjust_scroll (entry);
 }
 
 static void
@@ -723,10 +725,9 @@ gtk_entry_size_allocate (GtkWidget     *widget,
                              allocation->width - widget->style->xthickness * 2,
                              requisition.height - widget->style->ythickness * 2);
 
+      /* And make sure the cursor is on screen */
+      entry_adjust_scroll (entry);
     }
-
-  /* And make sure the cursor is on screen */
-  entry_adjust_scroll (entry);
 }
 
 static void
@@ -1387,11 +1388,13 @@ entry_adjust_scroll (GtkEntry *entry)
   g_return_if_fail (GTK_IS_ENTRY (entry));
 
   widget = GTK_WIDGET (entry);
-  text_area_width = widget->allocation.width - 2 * (widget->style->xthickness + INNER_BORDER);
 
-  if (!entry->layout)
+  if (!entry->layout || !GTK_WIDGET_REALIZED (entry))
     return;
   
+  gdk_window_get_size (entry->text_area, &text_area_width, NULL);
+  text_area_width -= 2 * INNER_BORDER;
+
   line = pango_layout_get_lines (entry->layout)->data;
   
   /* Display as much text as we can */